var baseUrl = 'http://localhost:9999'
//接口封装
function request(datas) {
	//Promise 异步编程的一种解决方案
	var promise = new Promise((resolve, reject) => {
		uni.request({
			url: baseUrl + datas.url,
			data: datas.data || {},
			method: datas.method || 'GET',
			header: {
				'Authorization':'Bearer '+ datas.Authorization,
				'content-type': datas.type ||
					'application/json;charset=UTF-8', //内容类型(默认 application/json;charset=UTF-8)
			},
			success: function(res) {
				resolve(res) 
			},
			fail: function(err) {
				console.log(err)
				reject(err)
			}
		})
	})
	return promise;
}
module.exports = request;
